﻿@** Copyright 2013 Seven Spikes Ltd. All rights reserved. (http://www.nop-templates.com)
* http://www.nop-templates.com/t/licensinginfo
*@

@using Nop.Core.Infrastructure
@model SevenSpikes.Nop.Plugins.MegaMenu.Models.MegaMenuCategoriesModels
@if (Model.CategoriesModels.Count > 0)
{
    var megaMenuSettings = EngineContext.Current.Resolve<SevenSpikes.Nop.Plugins.MegaMenu.Domain.MegaMenuSettings>();
    if (megaMenuSettings.ShowCategoriesInASingleMenuItem)
    {
    <li>
        @if (Model.CategoriesModels.Count > 0)
        {
            <div class="nav-item-wrapper">
                <span>@T("SevenSpikes.MegaMenu.Admin.Settings.MenuItemNameValue")</span>
                <div class="plus-button"></div>
            </div>
            <div class="dropdown">
                <ul>
                    @foreach (var category in Model.CategoriesModels)
                    {
                        <li>
                            @if (category.SubCategories.Count > 0)
                            {
                                <div class="nav-item-wrapper">
                                    <a href="@Url.RouteUrl("Category", new { SeName = category.CategoryModel.SeName })">@category.CategoryModel.Name</a>
                                    <div class="plus-button"></div>
                                </div>
                                <div class="dropdown inner-dropdown">

                                    <ul>
                                        @{
                                var categoriesCounter = 0;
                                foreach (var subCategory in category.SubCategories)
                                {
                                    categoriesCounter++;
                                
                                            <li>
                                                <a href="@Url.RouteUrl("Category", new { SeName = subCategory.CategoryModel.SeName })">@subCategory.CategoryModel.Name</a>
                                            </li>
                                
                                
                                    if (categoriesCounter == megaMenuSettings.NumberOfCategories && megaMenuSettings.NumberOfCategories != 0)
                                    {
                                            <li>
                                                <a class="view-all" href="@Url.RouteUrl("Category", new { SeName = category.CategoryModel.SeName })">@T("SevenSpikes.MegaMenu.ViewAllCategories")</a>
                                            </li>
                                
                                        break;
                                    }

                                }
                                        }
                                    </ul>
                                </div>
                                <!--dropdown-->
                            }
                            else
                            {
                                <a href="@Url.RouteUrl("Category", new { SeName = category.CategoryModel.SeName })">@category.CategoryModel.Name</a>
                            }
                        </li>
                    }
                </ul>
            </div>
            <!--dropdown-->
        }
        else
        {
            <a href="#">@T("SevenSpikes.MegaMenu.Admin.Settings.MenuItemNameValue")</a>
        }
    </li>
    }
    else
    {
        foreach (var category in Model.CategoriesModels)
        {
    <li>
        @if (category.SubCategories.Count > 0)
        {
            <div class="nav-item-wrapper">
                <a href="@Url.RouteUrl("Category", new { SeName = category.CategoryModel.SeName })">@category.CategoryModel.Name</a>
                <div class="plus-button"></div>
            </div>
            <div class="dropdown">

                <ul>
                    @{
            var categoriesCounter = 0;
            foreach (var subCategory in category.SubCategories)
            {
                categoriesCounter++;
                                
                        <li>
                            <a href="@Url.RouteUrl("Category", new { SeName = subCategory.CategoryModel.SeName })">@subCategory.CategoryModel.Name</a>
                        </li>
                                
                                
                if (categoriesCounter == megaMenuSettings.NumberOfCategories && megaMenuSettings.NumberOfCategories != 0)
                {
                        <li>
                            <a class="view-all" href="@Url.RouteUrl("Category", new { SeName = category.CategoryModel.SeName })">@T("SevenSpikes.MegaMenu.ViewAllCategories")</a>
                        </li>
                                
                    break;
                }

            }
                    }
                </ul>
            </div>
            <!--dropdown-->
        }
        else
        {
            <a href="@Url.RouteUrl("Category", new { SeName = category.CategoryModel.SeName })">@category.CategoryModel.Name</a>}
    </li>
        }
    }
}
